package com.wkq.util.transformer

import android.view.View
import androidx.viewpager2.widget.ViewPager2

/**
 *
 *@Author: wkq
 *
 *@Time: 2025/7/30 10:09
 *
 *@Desc:  AccordionPageTransformer 实现
 */
class AccordionPageTransformer : ViewPager2.PageTransformer {
    override fun transformPage(page: View, position: Float) {
        when {
            position < -1 || position > 1 -> {
                page.scaleX = 1f
            }

            position <= 0 -> {
                // 正在向左滑，当前页缩小
                page.pivotX = page.width.toFloat()
                page.scaleX = 1 + position
            }

            position <= 1 -> {
                // 正在向右滑，下一个页展开
                page.pivotX = 0f
                page.scaleX = 1 - position
            }
        }
    }
}
